import socket
import random, time

HOST = '127.0.0.1'
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

while True:
    str_ = str(random.randint(1, 456789054))
    s.sendall(("部番号:" + str_).encode('utf8'))
    print("发送数据:", str_)
    data = s.recv(1024)
    # print('接收到服务器返回数据: ', repr(data.decode('utf8')))
    print('接收到服务器返回数据: ', repr(data.decode()))
    time.sleep(random.randint(1, 5))

s.close()